﻿Solution solution = new Solution();
// add your code here for debugging

static ListNode? ToListNodes(IEnumerable<int> ints)
{
    ListNode listNode = new ListNode();
    ListNode? last = null;
    var current = listNode;
    foreach (var item in ints)
    {
        current.val = item;
        last = current;
        current = current.next = new ListNode();
    }
    if (last != null)
    {
        last.next = null;
        return listNode;
    }
    else
        return null;
}
solution.SwapPairs(ToListNodes(new int[] { 1, 2, 3, 4 })!);